﻿@model IEnumerable<商品后台mvcdemo.Models.ProductInfo>

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>商品后台</title>
</head>
<body>
    <p>
        @Html.ActionLink("新增商品", "Create")
    </p>
    <form action="Index" method="post">
        <input type="text" name="Name" />
        <input type="submit" value="查询" />
    </form>
    <table class="table">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Price)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.AddTime)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.State)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Proimage)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TypeInfo.TypeName)
            </th>
            <th>操作</th>
        </tr>
    
    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Price)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.AddTime)
            </td>
            <td>
                @* @Html.DisplayFor(modelItem => item.State)*@
                @if (item.State == 1)
                {
                    <p style="color:red">未上架</p>
                }
                else if (item.State == 0)
                {
                    <p style="color:#09c935">已上架</p>
                }
            </td>
            <td>
               @* @Html.DisplayFor(modelItem => item.Proimage)*@
                <img src="~/Image/@item.Proimage" width="100"height="100" />
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.TypeInfo.TypeName)
            </td>
            <td>
                @Html.ActionLink("修改", "Edit", new { id=item.ID }) |
                @Html.ActionLink("详情", "Details", new { id=item.ID }) |
                @Html.ActionLink("删除", "Delete", new { id=item.ID })
            </td>
        </tr>
    }
    
    </table>
</body>
</html>
